<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<div class="container-fluid">
	<div class="tabbable" id="tabs-598782">
		<ul class="nav nav-tabs">
			<li><a href="" data-toggle="tab" id="finance" style="border-bottom:#DDDDDD solid 1px;">财务明细</a>
			</li>
		</ul>
		<!-- 充值列表容器 -->
		<div class="tab-pane active" id="financeList" > </div>
	</div>
</div>
<script type="text/html" id="financeList-template">
<table class="table table-striped table-hover table-bordered">
	<thead>
		<tr><th>id</th>
			<th>用户名</th>
			<th>累计交易金额</th>
			<th>服务名称</th>
			<th>消费金额</th>
			<th>首次消费时间</th>
		</tr>
	</thead>
	<tbody >
		<$for(var i = 0;i<result.length;i++){$>
		<tr>
			<td>
				<$=result[i].user.id$>
			</td>
			<td>
				<a href="#" class="user" data='<$=result[i].user.id$>' title="点击查看财务详情"><$=result[i].user.name$></a>
			</td>
			<td>
				<$=result[i].userSumFund$>
			</td>
			<td>
				<$if(result[i].project!=null){$><a href="#" class="project" data='<$=result[i].project.id$>' title="点击查看财务详情"><$=result[i].project.name$></a><$}else{print("暂无资助服务");}$>
			</td>
			<td>
				<$if(result[i].support==0){print("暂无资助");}else{print(result[i].support);}$>
			</td>
			<td>
				<$if(result[i].date!=null){print(result[i].date);}else{print("暂无资助");}$>
			</td>
		</tr>
	<$}$>
	</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>	
<$ } $>
</script>

<script type="text/html" id="fund-table-template">
<$if(result[0]!=null){$>
<div><$
switch(result[0].user.roles){
			case 'sa':
			print("超级管理员");
			break;
			case 'admin':
			print("管理员");
			break;
			case 'institution':
			print("个人服务商");
			break;
			case 'user':
			print("普通");
			break;	
}$>用户 <strong> <$=result[0].userName$></strong> 的收支情况</div>
<div>账户余额：<$=result[0].user.fund$></div>
<$
	var zc=0;
	var sr=0;
for(var i = 0;i<result.length;i++){
	if ( result[i].actionType == 1 ||result[i].actionType == 2 || result[i].actionType == 4) { 
		sr+=result[i].amount;
	}else if ( result[i].actionType == 0 || result[i].actionType == 6){
		zc+=result[i].amount;
	}
}$>
<div>本页收入：<span id="sr"><$=sr$></span></div>
<div>本页支出：<span id="zc"><$=zc$></span></div>
<table class="table table-striped">
	<thead>
		<tr>
			<th>订单号</th>
			<th >时间</th>
			<th >详情</th>
			<th >收支</th>
			<th >金额（元）</th>
		</tr>
	</thead>
	<tbody id="fund-detail-tbody">
		<$for(var i = 0;i<result.length;i++){$>
			<$
				var meg = '';
				if(result[i].payType== '0'){
					msg ="支付宝账户："+  result[i].account;
				}else{
					msg = "银行账户："+ result[i].bank + result[i].account;
				}
			$>
			<tr>
					<td><$=result[i].tradeNo$></td>
					<td ><$=result[i].createdDate$></td>
			<$switch (result[i].actionType){
				case 0:$>	
					<td>支持<b><$="<<"$><$=result[i].project.name$><$=">>"$></b></td>
					<td style="color:red;">支出</td>
					<$break;
				case 1:$>
					<td>支付宝充值</td>
					<td class="brown" style="color:green;">收入</td>
					<$break;
				case 2:$>
					<td>使用优惠券</td>
					<td class="brown" style="color:green;">收入</td>
					<$break;
				case 3:$>	
					<td>充值未生效订单</td>
					<td style="color:gray;">收入</td>
					<$break;
				case 4:$>	
					<td><b><$="<<"$><$=result[i].project.name$><$=">>"$></b>中的服务<b><$="<"$><$=result[i].product.name$><$=">"$></b></td>
					<td style="color:green;">收入</td>
					<$break;
				case 5:$>
					<td>提现申请中 <$=msg$> </td>	
					<td style="color:gray;">支出</td>
					<$break;
				case 6:$>	
					<td>提现成功 <$=msg$></td>
					<td style="color:red;">支出</td>
					<$break;
				case 7:$>	
					<td>提现失败 <$=msg$></td>
					<td style="color:gray;">支出</td>
					<$break;
			}$>
					<td class="fundInfor"><$=result[i].amount$></td>			
			</tr>
		<$}$>
	</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>
<$}}else{print("该用户还没有收支情况");}$>
<div class="hf btn btn-link">返回</div>
</script>
<!-- 最新资助 -->
<script type="text/html" id="support-template">
<$if(result!=null){$>
<div>服务<strong><$=result[0].projectName$></strong>资助详情</div>
<div>目标金额：<$=result[0].project.fundTarget$></div>
<div>当前筹款：<$=result[0].project.fundCurrent$></div>
<table class="table table-striped">
<thead>
	<tr>
		<th >用户名称</th>
		<th>订单号</th>
		<th>资助单价</th>
		<th>资助金额</th>
		<th>成交时间</th>
	</tr>
</thead>
<tbody >							
<$for(var i = 0;i<result.length;i++){$>
	<tr>
		<td><$=result[i].userName$></td>
		<td><$=result[i].fundCode$></td>
		<td><$=result[i].productPrice$></td>
		<td><$=result[i].productPrice * result[i].productAmount$></td>
		<td><$=result[i].createdDate$></td>
	</tr>

<$}$>
</tbody>
						</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>
<$ } }else{$>该服务还没有收支情况<$}$>
<div class="hf btn btn-link">返回</div>
</script>
<c:if test="${env == 'production' }">
<script type="text/javascript">
	seajs.use("${ctx}/assets/js-dist/admin/finance-list-page");
</script>
</c:if>
<c:if test="${env != 'production' }">
<script type="text/javascript">
	seajs.use("${ctx}/assets/js/admin/finance-list-page");
</script>
</c:if>
